package com.network.network;

/**
 * Created by Bruce on 2017/7/1.
 */

public class DataList {
    private DataBean head;
    private DataBean move;

    public void addData(String name, String data) {
        if (head == null) {
            head = new DataBean();
            move = head;
            move.name = name;
            move.data = data;
            move.next = null;
        } else {
            DataBean tem = new DataBean();
            move.next = tem;
            tem.name = name;
            tem.data = data;
            tem.next = null;
            move=tem;
        }
    }

    public String getAllDataForPOST() {
        StringBuilder sb = new StringBuilder();
        DataBean move = head;
        while (move!= null) {
            sb.append(move.name);
            sb.append("=");
            sb.append(move.data);
            sb.append("&");
            move=move.next;
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }

    public String getAllDataForGET() {
        StringBuilder sb = new StringBuilder();
        DataBean move = head;
        sb.append("?");
        while (move != null) {
            sb.append(move.name);
            sb.append("=");
            sb.append(move.data);
            sb.append("&");
            move=move.next;
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }
}
